#include <windows.h>
#include <d3d11_1.h>
#include <directxcolors.h>
#include "CGraphic.h"
using namespace tri;

int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

	CGraphic graphic;
    if( FAILED( graphic.InitWindow( hInstance, nCmdShow ) ) )
        return 0;

    if( FAILED( graphic.InitDevice() ) )
    {
        graphic.CleanupDevice();
        return 0;
    }

    MSG msg = {0};
    while( WM_QUIT != msg.message )
    {
        if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
        {
            graphic.Render();
        }
    }

    graphic.CleanupDevice();

    return ( int )msg.wParam;
}
